function mjd = serial2MJD(sd)
%serial2MJD - MATLAB serial date to modified julian date conversion
%
%       MJD = serial2MJD(SD)
%
% Let SD be vector of serial dates. This function computes the corresponding 
% vector of modified julian dates MJD (e.g., 732314, which corresponds to 
% 2-Jan-2005, is converted into 53372. The initial MJD date, i.e. the MJD
% day 1, is 18-Nov-1858).
%
% See also date2gpsw, gpsw2serial, frac2MJD, MJD2frac, serial2frac, 
% frac2serial, serial2YMD, MJD2serial, leapy.

% G. Teza, 2021

sd = sd(:);       % to have a column vector
sd = double(sd);
 
T = datetime(sd,'ConvertFrom','datenum');
mjd = juliandate(T,'modifiedjuliandate');